#define _CRT_SECURE_NO_WARNINGS   1
#include "SepList.h"

void InitSL(SL* sl) {
	sl->a = (SLtype*)malloc(4 * sizeof(SLtype));
	if (NULL == sl->a)
	{
		perror("malloc fail");
		return;

	}
	sl->size = 0;
	sl->capacity = 4;


}

void DstroySL(SL* sl){
free(sl->a);
sl->a = NULL;
sl->size;
sl->capacity = 0;


}
int  SLCheckCapacity(SL*sl){

	if (sl->size == sl->capacity)
	{
		SLtype* tmp = (SLtype*)realloc(sl->a, (2 * sl->capacity)*sizeof(SLtype));
		if (NULL == tmp)
		{
			perror("realloc fail");
			
		}
		

	}
	sl->capacity *= 2;

}

void Pushfront(SL* sl,SLtype value) {
	int r = SLCheckCapacity(sl);
	
	int i = 0;
	for(i = sl->size; i > 0; i--)
	{
		sl->a[i] = sl->a [i - 1] ;

	}
	sl->a[0] = value;
	sl->size += 1;


}
void PrintInit(SL* sl)
{
	for (int i = 0; i < sl->size; i++)
	{
		printf("%d", sl->a[i]);

	}


}



void Pushback(SL* sl);
void Popfront(SL* sl);
void Pophfront(SL* sl);


